package com.earthchen;

/**
 * 冒泡排序
 *
 * @author earthchen
 * @date 2018/8/10
 **/
public class BubbleSort {


    public static void sort(int[] numbers) {

        int temp = 0;
        int size = numbers.length;
        for (int i = 0; i < size - 1; i++) {
            for (int j = 0; j < size - 1 - i; j++) {
                //交换两数位置
                if (numbers[j] > numbers[j + 1]) {
                    temp = numbers[j];
                    numbers[j] = numbers[j + 1];
                    numbers[j + 1] = temp;
                }
            }
        }
    }
}
